Model numerical solver for system control

ABSTRACT

A complete model numerical solver resides on an embedded processor for real time control of a system. The solver eliminates the need for custom embedded code, requiring only model equations, definition of the independent and dependent variables, parameters and input sources information as input to solve the model equations directly. Through elimination of the need for custom code, the solver speeds up the model deployment process and provides the control application sophisticated features such as Automatic Differentiation, sensitivity analysis, sparse linear algebra techniques and adaptive step size in solving the model concurrently.

CROSS REFERENCE APPLICATIONS

This application claims the benefit of provisional application No.62/147,312 filed Apr. 14, 2015 and incorporated herein by reference forall purposes.

TECHNICAL FIELD

The present invention relates to adaptive control of an embedded system.More specifically, the invention relates to a model numerical solverprogram for use with a model description in an embedded processor of acontrol system.

BACKGROUND

In various control applications and for the present invention, amathematical model refers to a set of mathematical equations relatingdependent variables and independent variables. That is, those equationsdefine explicitly or implicitly a set of dependent variables asfunctions of independent variables. The equations of a model can eitherbe differential (the derivative of at least one dependent variable withrespect to an independent variable appears in the equation) or algebraic(no derivative appears in the equation), and for the present inventionat least one of the model equations is differential. Those equations caninvolve numerical quantities referred to as parameters which do notdepend on any of the model variables, and whose values lie between fixedupper and lower bounds. In addition, the model equations includefunctions of the independent variables referred to as input sources,whose values can be arbitrarily controlled and defined. A modeldescription therefore consists of a list of differential and algebraicequations together with a list of dependent and independent variables,the values and ranges of the parameters, and the definition of the inputsources in terms of the independent variables. The purpose of a modelnumerical solver software is to perform the computational tasks requiredto obtain the values of the dependent variables as numerical functionsof the independent variables, parameters and input sources. It isimportant to note that, the numerical routines used to solve the modelequations are model-agnostic.

Control methods referred to as Model Reference Adaptive Control requirethe capability of updating the model parameters to achieve a pre-definedgoal while operating the controlled system, such as minimizing the errorbetween the model prediction and the controlled system actual response.This can be achieved by the model numerical solver through the use of anumerical optimizer which computes the optimal values of the modelparameters with respect to a pre-defined goal. The numerical optimizershould guarantee that the computed optimal values of the parameters liewithin the lower and upper bounds defined in the model description.

Mathematical models are used in various control applications rangingfrom mechatronics to industrial systems controls. These models aretypically described by a set of non-linear Differential AlgebraicEquations (DAE) for which an analytical solution either is not known ordoes not exist. Modern numerical techniques are extremely efficient forobtaining numerical solutions of such equations. For systems describedby a set of Partial Differential Equations (PDE) spatial discretizationschemes are employed to transform them into a set of DAEs.

Real time control methods require such models to be ported into anembedded processor and solved in “real time” relative to the timeconstants of the controlled process. Some advanced control methods suchas Model Reference Adaptive Control (MRAC) also involve updating theparameters of the model in real time in order to minimize error or adaptto changes in the controlled system.

So far the process of model development/optimization and its embeddedimplementation has been a two-step process. First the model is developedand optimized in a general purpose Computer Aided Engineering (CAE)environment. After the model has been verified and optimized custommodel code is generated either automatically or manually.

The two-step process has the following drawbacks:

-   -   1. The code produced does not contain all the functionality        available in the CAE environment. For example the Embedded Coder        of MATLAB™ does not provide essential numerical routines such as        the DAE solver itself. The resulting software is compromised as        it cannot benefit from features such as an efficient DAE solver        or runtime sensitivity analysis which may be required in certain        adaptive control applications. Other features that affect        computational performance such as adaptive step-size are also        not included.    -   2. Any change in the model itself requires repetition of the        two-step process. If the code is produced manually it adds        significantly to the cost of the system.

Accordingly, a solution which minimizes or eliminates these currentdrawbacks to model development and its embedded implementation would bebeneficial.

SUMMARY OF THE INVENTION

The present application discloses a complete model numerical solver thatis small enough to reside on an embedded processor. It contains all thefeatures of a State-of-the-Art solver including AutomaticDifferentiation (AD), complete DAE solver like IDAS or DASSL, sparselinear algebra techniques, sensitivity analysis, numerical optimizer andadaptive step size. It accomplishes all these functions in a few hundredKB of code space (depending on enabled features) without requiringcreation of custom embedded code. All an operator needs to input is themodel description (as explained above), as one would input them in ageneral purpose CAE package.

It should be appreciated that for porting a model numerical solver intoan embedded processor the designer has to work within the constraints ofa finite memory size.

The complex computational steps associated with solving a set ofalgebraic differential equations describing a model require memoryallocations (for example, allocating memory to an array in order toperform a linear algebra operation). Those memory allocations aretraditionally dynamic allocations, i.e. memory is allocated “on the fly”during run time without a-priori knowledge of the exact amount of spaceneeded. Dynamic allocation is by nature non-deterministic. The timerequired to “find” the requested memory space will depend both on thesize of memory requested as well as the memory occupation by otherprocesses executed on the embedded processor. Any task associated withdynamic memory allocation can thus take an arbitrarily long time or evenfail. This is not the case with “static memory allocation” where theexact memory size requirement must be known at compile time.

Prior art model solvers, designed for environments with much highercomputing and memory resources than those of an embedded processor, usedynamic memory allocation. For example, the SUNDIALS (Suite of Nonlinearand Differential/Algebraic equation solvers) software package developedby Lawrence Livermore National Laboratory is considered to represent thestate of the art for numerical solvers for ordinary and algebraicdifferential equations. In the code examples shipped with the SUNDIALSsoftware package (e.g., cvsDiurnal_FSA_kry.c) it is shown that dynamicmemory allocations are performed at each solving step.

It is obvious that for a task that must be executed in real time, thememory requirements of prior art and resulting unpredictable executiontime are unacceptable in a safety critical application such as batterymanagement, which requires continuous monitoring and control in realtime.

The present invention model numerical solver implements a specificmemory layout and memory allocation strategy to address those issues.

Once a model is defined, the numerical solver of the present inventionautomatically estimates an upper bound on the memory requirements forthe various components of the solver (i.e., model variables, solver datastructures and solver internal memory requirements, additional memorypools; see FIG. 6). The present invention solver then proceeds with theallocation of all the required memory during the instantiation andinitialization phase. In particular, this allocation of the model dataincludes allocating memory pools, i.e. memory segments that can beshared among the solver tasks. Those memory pools are used to performmemory allocation during the solving steps, the advantage being thatthose allocations are equivalent to static allocations since the memoryhas already been allocated for the pool and its size cannot be exceededby any solver process. This implies that the model numerical solver ofthe present invention guarantees that after the instantiation andinitialization phase no dynamic memory allocation will be performed.This is a difference compared to the prior art.

These methods make possible performance of the computational tasksassociated with solving differential equations within the microprocessorof an embedded device and are thus able to guarantee a deterministicresponse time.

The present invention: eliminates the need for custom model code bysolving the model equations directly; speeds up the model deploymenteffort; is more reliable and cost effective as it eliminates one step inthe model deployment process; makes available to the control applicationsophisticated solver features such as Automatic Differentiation,sensitivity analysis, sparse linear algebra techniques and adaptive stepsize. The model numerical solver of the present invention is suitablefor stiff problems such as the battery modeling problem.

According to the present invention, the model solver program is writtenin modern C++ and provides a clean, stable and well-documented API(Application Programming Interface) making possible convenientinterfacing with external software and use of the model numericalsolver's features in a wide range of applications.

The description of the model can be input into the program using one ofthe following methods:

-   -   A Functional Mock-up Interface (FMI) description of the model        (FMI is a standardized interface for the description of complex        physical systems).    -   A C++ source file that will be evaluated at compile time        containing at least the definition of a numerical routine to        evaluate the dependent variables of the model as numerical        functions for the independent variables, parameters and input        sources.    -   A XML/MathML file describing the equations of the model and        listing the parameters, which makes it possible to use available        parsers to convert the description of the model in other formats        (for example, LaTeX or HTML).

BRIEF DESCRIPTION OF THE DRAWINGS

The invention will be described with respect to a drawing in severalfigures, of which:

FIG. 1 is a prior art illustration of model based adaptive control asimplemented in a Battery Management System.

FIG. 2 is a prior art illustration of a typical two-step process formodel development and deployment in an embedded environment.

FIG. 3 is an illustration of model equations solved directly in anembedded processor according to the present invention.

FIG. 4 is an illustration of the model numerical solver structure asimplemented in the invention.

FIG. 5 is an example of an arrangement of the present invention in aphysical battery system.

FIG. 6 is an exemplary memory allocation of the present invention.

FIG. 7 is a comparison between the memory strategy of the model solverin the present invention and a traditional memory strategy.

FIG. 8 shows the model/simulator performance in a single cell simulationin real time under random current load.

DETAILED DESCRIPTION

A model based adaptive control system as implemented in a BatteryManagement System is shown in FIG. 1. The battery model 10 and stateestimator 12 receive information as input sources from the battery 16indicating a present state of the battery. The battery model 10 andstate estimator 12 use this information to calculate an estimation of afuture state of the battery. This estimation is communicated to controlalgorithms 18 which control operation of the battery 16 according totheir own performance standards.

A typical two-step process for model development and deployment in anembedded environment is shown in FIG. 2. A developer enters the modeldescription 20 into a general purpose CAE environment 22 which optimizesand generates custom code either automatically or manually. After thisinitial step, the generated code 26 is then provided to the embeddedenvironment 28 of the specific system.

FIG. 3 is an illustration of the model numerical solver operationaccording to the invention. Model description 30 is entered directlyinto the embedded environment 38. The embedded environment 38 containsthe model numerical solver, which solves the model equations 30 directlyand concurrently.

The structure and operation of the model numerical solver is illustratedin FIG. 4. Model equations 40 and model parameters 45 are defined andprovided to a model 48. Refinement of the model is possible throughuser-controlled solver parameters 42 and optimizer parameters 43. Modelsolving is performed in the solver 44 and model optimization isperformed in the model optimizer 41.

FIG. 5 is an example of an arrangement of the invention in a physicalbattery system. A physical battery system 50 includes a battery 52driving a load 54. The battery 52 and the load 54 provide informationvalues to an embedded processor 56 related to the present state of thebattery and the load requirements. The model numerical solver 51 of thepresent invention resides within a memory of the embedded processor 56and, after solving the model equations for the provided values,estimates a future state of the battery and communicates this futurestate to a control application 53. The control application 53 determinesthe operation of a battery management system 58, which optimizescharacteristics of the battery 52.

An exemplary memory allocation of the present invention is shown in FIG.6.

FIG. 7 provides a comparison between the memory strategy 70 of the modelsolver in the present invention and a traditional memory strategy 72.

To evaluate the real-time capabilities and portability of the solver, asingle cell simulation on a commercial development board was performed.The board used was the PandaBoard [25] with a Dual-core ARM® Cortex™-A9MPCore™ at 1 GHz and 1 GB of memory. A physical cell was exercised underrandom current loads. The varying current values were read and presentedto the solver along with the environment temperature. The cell voltageand temperature predicted by the simulation was then compared to theactual voltage and temperature produced by the physical cell. FIG. 8shows the model/simulator performance in real time under random load.The average computational time was 12 ms, which is 4.1 times faster thanthe simulation step used of ˜50 ms. The model used includes: 13dependent variables, 7 function parameters and 17 scalar parameters.

Disclosed herein is a method for performing model computations within anembedded processor, which involves loading a model numerical solversoftware program into a memory of the embedded processor and defining amodel description which itself includes a list of independent anddependent variables, parameters values and bounds, input sources, andmodel differential and algebraic equations, then inputting the modeldescription into the model solver, estimating an upper bound on thetotal memory requirement for the model numerical solver computationaltasks for the particular model description, allocating required amountsof memory during instantiation and initialization of the model numericalsolver as determined by the estimation of the upper bound for the totalmemory requirement of the model numerical solver for the particularmodel description prior to commencement of solver steps, receiving atthe model solver at least one value for at least one independentvariable of the model equations, solving the model equations directlyand concurrently with the solver numerical routines and outputting atleast one value of one of the dependent variables. With this method,inputting the model description may involve a Functional Mock-upInterface (FMI) description of the model, a C++ source file containingat least the definition of a numerical routine to evaluate the dependentvariables of the model as numerical functions for the independentvariables, parameters and input sources, or an XML/MathML filedescribing the model description as a list of independent and dependentvariables, parameters values and bounds, input sources and differentialand algebraic equations. The model numerical solver software program ofthe method may include Automatic Differentiation (AD), a completeDifferential Algebraic Equation solver, sparse linear algebratechniques, sensitivity analysis, numerical model optimization andadaptive step-size. The method may also provide user-controllable solverparameters and optimizer parameters.

Also disclosed herein is a method for controlling a system whichinvolves embedding a processor into an electronic device, loading amodel solver software program into a memory of the embedded processor,defining a model description which itself includes a list of independentand dependent variables, parameters values and bounds, input sources,and model differential and algebraic equations, then inputting the modeldescription into the model solver, estimating an upper bound on thetotal memory requirement for the numerical solver computational tasksfor the particular model description, allocating required amounts ofmemory during instantiation and initialization of the model numericalsolver as determined by the estimation of the upper bound for the totalmemory requirement of the model numerical solver computational tasks forthe particular model description and prior to commencement of solversteps, receiving at the model solver at least one value for at least onevariable of the model equations, solving the model equations directlyand concurrently with the solver numerical routines, outputting at leastone value of one dependent variable of the model equations and receivingthe at least one value of one dependent variable at a controller,wherein the controller effects changes to the state of the system inresponse to receiving the at least one value of one dependent variable.With this method, inputting the model description may involve aFunctional Mock-up Interface (FMI) description of the model, a C++source file containing at least the definition of a numerical routine toevaluate the dependent variables of the model as numerical functions forthe independent variables, parameters and input sources, or anXML/MathML file describing the model description as a list ofindependent and dependent variables, parameters values and bounds, inputsources and differential and algebraic equations. The model numericalsolver software program of the method may include AutomaticDifferentiation (AD), a complete Differential Algebraic Equation solver,sparse linear algebra techniques, sensitivity analysis, numerical modeloptimization and adaptive step-size. The method may also provideuser-controllable solver parameters and optimizer parameters.

A model solver software program in a memory of an embedded processor asherein disclosed may include a list of independent and dependentvariables, parameters values and bounds, input sources, and modeldifferential and algebraic equations, a memory structure wherein themodel solver estimates an upper bound on the total memory requirementfor the model numerical solver computational tasks for the particularmodel description and wherein required amounts of memory are allocatedduring instantiation and initialization of the model simulation asdetermined by the upper bound estimation for the total memoryrequirement of the model numerical solver computational tasks for thisparticular model description and prior to commencement of solver steps,means for receiving at least one input signal from at least one sourceand computational means for solving at least two equations concurrently.This model solver software program may receive input signals from aFunctional Mock-up Interface (FMI) description of the model, a C++source file containing at least the definition of a numerical routine toevaluate the dependent variables of the model as numerical functions forthe independent variables, parameters and input sources, or anXML/MathML file describing the model as a list of independent anddependent variables, parameters values and bounds, input sources anddifferential and algebraic equations. The model solver program of themethod may include an Automatic Differentiation (AD) feature, a completeDifferential Algebraic Equation solver, sparse matrix techniques,sensitivities computation, AC small signal analysis and adaptivestep-size. The model numerical solver software program may includeAutomatic Differentiation (AD), a complete Differential AlgebraicEquation solver, sparse linear algebra techniques, sensitivity analysis,numerical model optimization and adaptive step-size. An alert andthoughtful reader will have no difficulty devising myriad variations,improvements and applications of the solver and methods disclosedherein. All such variations, improvements and applications are intendedto be encompassed within the claims that follow.

1. A method for controlling a physical battery system by means of modelcomputations within an embedded processor, comprising the steps of:defining a model description, the model description comprising: a listof independent and dependent variables, parameter values and bounds,input sources, and model equations, at least one of which isdifferential; inputting the model description into a model numericalsolver; loading the model numerical solver into a memory of the embeddedprocessor; estimating an upper bound on the total memory requirement ofcomputational tasks for the model numerical solver for the inputtedmodel description, wherein no dynamic memory allocations beyond theupper-bound of total memory estimate are allowed for runtimecomputational tasks; statically allocating required amounts of memoryduring instantiation and initialization of a model simulation asdetermined by the estimation of the upper bound on the total memoryrequirement of the computational tasks for the model numerical solverfor the imputed model description prior to commencement of solver steps;by the model numerical solver, directly and concurrently receiving themodel equations; solving numerically the model equations with the modelnumerical solver; outputting at least one value of the dependentvariable of the model equations to a control application; receiving theat least one value of one dependent variable at the control application;and effecting changes to the state of the physical battery system by thecontrol application, without making any dynamic memory allocations, inresponse to receiving the at least one value of one dependent variable,wherein a deterministic response time is guaranteed.
 2. The method ofclaim 1, wherein the inputting the model description step comprises aFunctional Mock-up Interface (FMI) description of the model.
 3. Themethod of claim 1, wherein the inputting the model description stepcomprises a C++source file containing at least the definition of anumerical routine to evaluate the dependent variables of the model asnumerical functions for the independent variables, parameters and inputsources.
 4. The method of claim 1, wherein the inputting the modeldescription step comprises a XML/MathML file describing the model as alist of independent and dependent variables, parameter values andbounds, input sources, and differential and algebraic equations.
 5. Themethod of claim 1, wherein the model numerical solver comprisesnumerical routines for an Automatic Differentiation (AD) feature, acomplete Differential Algebraic Equation solver, sparse-linear-algebratechniques, sensitivity analysis, numerical model optimization, andadaptive step-size.
 6. The method of claim 1, further comprising thestep of providing user-controllable solver parameters and optimizerparameters.
 7. A method for improving task₌execution time in a physicalbattery system, comprising the steps of: embedding a processor into anelectronic device; defining a model description, the model descriptioncomprising: a list of independent and dependent variables, parametervalues and bounds, input sources, and model equations, at least one ofwhich is differential; inputting the model description into a modelnumerical solver; loading the model numerical solver into a memory ofthe embedded processor; estimating an upper bound on the total memoryrequirement of computational tasks for the model numerical solver forthe inputted model description, wherein no dynamic memory allocationsbeyond the upper-bound of total memory estimate are allowed for runtimecomputational tasks; statically allocating required amounts of memoryduring instantiation and initialization of a model simulation asdetermined by the estimation of the upper bound on the total memoryrequirement of the computational tasks for the model numerical solverfor the imputed model description prior to commencement of solver steps;by the model numerical solver, directly and concurrently receiving themodel equations; solving numerically the model equations with the modelnumerical solver; outputting at least one value of the dependentvariable of the model equations to a control application; receiving theat least one value of one dependent variable at the control application;and effecting changes to the state of the physical battery system by thecontrol application, without making any dynamic memory allocations, inresponse to receiving the at least one value of one dependent variable,wherein a deterministic response time is guaranteed.
 8. The method ofclaim 7, wherein the inputting the model description step comprises aFunctional Mock-up Interface (FMI) description of the model.
 9. Themethod of claim 7, wherein the inputting the model description stepcomprises a C++ source file containing at least the definition of anumerical routine to evaluate the dependent variables of the model asnumerical functions for the independent variables, parameters and inputsources.
 10. The method of claim 7, wherein the inputting the modeldescription step comprises a XML/MathML file describing the model as alist of independent and dependent variables, parameter values andbounds, input sources, and differential and algebraic equations.
 11. Themethod of claim 7, wherein the model numerical solver comprisesnumerical routines for an Automatic Differentiation (AD) feature, acomplete Differential Algebraic Equation solver, sparse-linear-algebratechniques, sensitivity analysis, numerical model optimization, andadaptive step-size.
 12. The method of claim 7, further comprising thestep of providing user-controllable solver parameters and optimizerparameters.